<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<title>排班详情</title>
	    <%@include file="/common/commonCSS.jsp" %>
	    <%@include file="/common/commonJS.jsp" %>
		<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
	</head>
	<body >
		<div class="main-container" id="main-container">
			<form class="form-horizontal  bv-form" id="schedulingForm">
				<div style="display: none">
					<input id="id" name="id"  value="${scheduling.id}"/>
				</div>
				<div class="row">
					<div class="form-group col-xs-12 ">
						<label class="col-sm-3 control-label no-padding-right"><i class="red"> * </i>值班类型:</label>
						<div class="col-xs-9">
							<span class="col-xs-11 block input-icon input-icon-right">
								<tag:select nameKey="duty_free" name="dutyFree" clazz="form-control" isAddDefaltOption="true" defaltOptionValue="--请选择--" initSelectedKey="${scheduling.dutyFree}"/>
							</span>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-xs-12 ">
						<label class="col-xs-3 control-label no-padding-right"><i class="red"> * </i>选择值班日期:</label>
						<div class="col-xs-9">
							<%--<div class="auto-kal" data-kal="mode:'multiple'"></div>--%>
							<span class="col-xs-11 block input-icon input-icon-right">
								<input type="text" name="days" class="auto-kal form-control" data-kal="mode:'multiple'">
							</span>
						</div>
					</div>
				</div>

				<div class="row">
					<div class="form-group col-xs-12 ">
						<label class="col-sm-3 control-label no-padding-right"><i class="red"> * </i>选择组:</label>
						<div class="col-xs-9">
							<span class="col-xs-11 block input-icon input-icon-right">
								<tag:select id="groups" name="schGroupId"  clazz="form-control" isJXdata="true" data="${groups}" isAddDefaltOption="true" defaltOptionValue="--请选择--"/>
							</span>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-xs-12 ">
						<label class="col-sm-3 control-label no-padding-right"><i class="red"> * </i>选择用户:</label>
						<div class="col-xs-9">
							<span class="col-xs-11 block input-icon input-icon-right">
								<select id="users"  class="form-control" name="schUserId">
									<option>--请选择--</option>
								</select>
							</span>
						</div>
					</div>
				</div>
				<div class="row" style="margin-left: 40%;padding-bottom: 28px;margin-top: 25px;">
					<button class="layui-btn" type="button" id="submitBtn">保 存</button>
					<a class="layui-btn layui-btn-normal" href="${webRoot}/scheduling/list">返 回</a>
				</div>
			</form>
		</div>
	</body>
	<script>

        $(document).ready(function(){
            $('#groups').change(function(){
                var groupId=$(this).children('option:selected').val();//这就是selected的值
				$.post("${webRoot}/scheduling/getGroupUser",{'groupId' :groupId},function (reslut) {
                    $("#users").empty();
                    for(var i=0; i < reslut.users.length; i++){
                        $("#users").append("<option  value='"+reslut.users[i].id+"'>"+reslut.users[i].userName+"</option>");
                    }
                },"json");
            });
        });
		//提交
		$("#submitBtn").click(function () {
			var url ="${webRoot}/scheduling/edit";
            checkFormValid($("#schedulingForm"),function () {
                $.post(url,$("#schedulingForm").serialize(),function (result) {
                    if(result.code == '0'){
                        if($("#id").val() == ''){
                            alert(result,function () {
                                location.href='${webRoot}/scheduling/list';
                            },function () {
                                $("#submitBtn").reset();
                            });
                        }else {
                            //更新成功，返回List页面
                            toast(result.msg);
                            location.href='${webRoot}/scheduling/list';
                        }
                    }else {
                        alertMsg(result.msg);
                    }

                });
            });

		});
	</script>
</html>